#include "CProduction_Unit.h"
#include <iostream>
#include "../NativeGrammar.h"

#include <string>
#include <stdlib.h>

using namespace std;

CTokenPtr CProduction_Unit_Number::Reduce( CProductionArgPtr pArgs )
{
    CTerminateTokenPtr pToken = pArgs->getArg<CTerminateToken>(0);

    int number = atoi(pToken->GetStringValue().c_str());   

    CUnitPtr pResult = CTokenFactory::createToken<CUnit>();

    pResult->m_int = number;

    return pResult;
}

CTokenPtr CProduction_Unit_Variable::Reduce( CProductionArgPtr pArgs )
{
	return CVariable::create(pArgs->getArg<CTerminateToken>(0)->GetStringValue());
}

CTokenPtr CProduction_Unit_String::Reduce( CProductionArgPtr pArgs )
{

	CTerminateTokenPtr pToken = pArgs->getArg<CTerminateToken>(0);

	CUnitPtr pResult = CTokenFactory::createToken<CUnit>();

	//BUGBUG 2010-04-29
	//BUGBUG 2010-04-29
	//BUGBUG 2010-04-29
	pResult->m_int = 0;
	return pResult;

}